package com.adams.custom.page.mgt.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.apache.log4j.Logger;
import org.springframework.beans.BeanUtils;

import com.adams.access.db.bean.DicColumn;
import com.adams.access.db.bean.DicTable;
import com.adams.access.db.bean.ViewEvent;
import com.adams.access.db.bean.ViewItem;
import com.adams.access.db.bean.ViewPanel;
import com.adams.access.db.bean.ViewPanelFilter;
import com.adams.access.db.bean.ViewWin;
import com.adams.core.exception.BusinessException;
import com.adams.custom.page.core.service.DicTableService;
import com.adams.custom.page.mgt.ViewTreeConfigDTO;
import com.adams.custom.page.mgt.dao.impl.ViewEventDaoImpl;
import com.adams.custom.page.mgt.dao.impl.ViewItemDaoImpl;
import com.adams.custom.page.mgt.dao.impl.ViewPanelDaoImpl;
import com.adams.custom.page.mgt.dao.impl.ViewPanelFilterDaoImpl;
import com.adams.custom.page.mgt.dao.impl.ViewWinDaoImpl;
import com.adams.custom.page.mgt.service.ViewCfgService;
import com.adams.custom.page.mgt.service.ViewParseService;
import com.adams.custom.page.util.ViewUtil;
import com.adams.encache.mechanism.CacheUtil;

/**
 * 
 * File Name : ViewServiceImpl.java
 * 
 * @Description : 界面定义服务类
 */
public class ViewCfgServiceImpl implements ViewCfgService
{
	Logger logger = Logger.getLogger(ViewCfgServiceImpl.class.getName());
	/**
	 * Description : 页面窗口实体数据访问实现类 Author : 904370
	 */
	private ViewWinDaoImpl viewWinDaoImpl;

	/**
	 * Description : 页面面板实体数据访问实现类 Author : 904370
	 */
	private ViewPanelDaoImpl viewPanelDaoImpl;

	/**
	 * Description : 页面信息项实体数据访问实现类 Author : 904370
	 */
	private ViewItemDaoImpl viewItemDaoImpl;

	/**
	 * Description : 页面面板表格按钮访问实现类 Author : 904202
	 */
	private ViewEventDaoImpl viewEventDaoImpl;

	/**
	 * Description : 动态数据服务类 Author : 904370
	 */
	private DicTableService dicTableService;

	/**
	 * Description : 界面服务接口 Author : 904370
	 */
	private ViewParseService viewParseService;

	/**
	 * Description : 界面面板自定义过滤条件实体数据访问实现类 Author : 904202
	 */
	private ViewPanelFilterDaoImpl viewPanelFilterDaoImpl;

	public void setViewPanelFilterDaoImpl(
			ViewPanelFilterDaoImpl viewPanelFilterDaoImpl)
	{
		this.viewPanelFilterDaoImpl = viewPanelFilterDaoImpl;
	}

	public void setViewParseService(ViewParseService viewParseService)
	{
		this.viewParseService = viewParseService;
	}

	public void setDicTableService(DicTableService dicTableService)
	{
		this.dicTableService = dicTableService;
	}

	public void setViewEventDaoImpl(ViewEventDaoImpl viewEventDaoImpl)
	{
		this.viewEventDaoImpl = viewEventDaoImpl;
	}

	/**
	 * @param viewItemDaoImpl
	 *            the viewItemDaoImpl to set
	 */
	public void setViewItemDaoImpl(ViewItemDaoImpl viewItemDaoImpl)
	{
		this.viewItemDaoImpl = viewItemDaoImpl;
	}

	/**
	 * @param viewWinDaoImpl
	 *            the viewWinDaoImpl to set
	 */
	public void setViewWinDaoImpl(ViewWinDaoImpl viewWinDaoImpl)
	{
		this.viewWinDaoImpl = viewWinDaoImpl;
	}

	/**
	 * @param viewPanelDaoImpl
	 *            the viewPanelDaoImpl to set
	 */
	public void setViewPanelDaoImpl(ViewPanelDaoImpl viewPanelDaoImpl)
	{
		this.viewPanelDaoImpl = viewPanelDaoImpl;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.impl.ViewCfgService#
	 * findViewWinByMenuid(java.lang.Long)
	 */
	public List<ViewWin> findViewWinByMenuid(Long menuid)
			throws BusinessException
	{
		logger.info("findViewWinByMenuid method run begin.");
		List<ViewWin> result = viewWinDaoImpl.findByMenuid(menuid);
		logger.info("findViewWinByMenuid method run end.");
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.impl.ViewCfgService#
	 * findViewWinByMenuidAndWintype(java.lang.Long, java.lang.String)
	 */
	public List<ViewWin> findViewWinByMenuidAndWintype(Long menuid,
			String wintype) throws BusinessException
	{
		logger.info("findViewWinByMenuidAndWintype method run begin.");
		List<ViewWin> result = viewWinDaoImpl.findViewWinByMenuidAndWintype(
				menuid, wintype);
		logger.info("findViewWinByMenuidAndWintype method run end.");
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.impl.ViewCfgService#
	 * saveOrUpdateViewWin(com.adams.access.db.bean.ViewWin)
	 */
	public void saveOrUpdateViewWin(ViewWin viewWin) throws BusinessException
	{
		logger.info("saveOrUpdateViewWin method run begin.");
		if (viewWin.getId() > 0 && viewWin.getVersion() == 0)
		{
			ViewWin old = viewWinDaoImpl.get(viewWin.getId());
			if (null != old)
			{
				viewWin.setVersion(old.getVersion());
				BeanUtils.copyProperties(viewWin, old);
				viewWin = old;
			}
		}
		viewWinDaoImpl.saveOrUpdate(viewWin);
		viewWinDaoImpl.synchronizationCache();
		viewParseService.clearCache();
		CacheUtil.clearCacheByClass(ViewWin.class);
		logger.info("saveOrUpdateViewWin method run end.");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.adams.custom.page.mgt.service.ViewCfgService#deleteViewWins
	 * (java.util.List)
	 */
	public void deleteViewWins(List<Long> viewwinids) throws BusinessException
	{
		logger.info("deleteViewWins method run begin.");
		try
		{
			for (Long viewwinid : viewwinids)
			{
				ViewWin viewWin = viewWinDaoImpl.get(viewwinid);
				deleteViewWinDB(viewWin);
				viewWinDaoImpl.delete(viewWin);
			}
		} finally
		{
			viewWinDaoImpl.synchronizationCache();
			viewPanelDaoImpl.synchronizationCache();
			viewParseService.clearCache();
			CacheUtil.clearCacheByClass(ViewWin.class);
			CacheUtil.clearCacheByClass(ViewPanel.class);
			CacheUtil.clearCacheByClass(ViewItem.class);
			CacheUtil.clearCacheByClass(ViewEvent.class);
		}
		logger.info("deleteViewWins method run end.");
	}

	private void deleteViewWinDB(ViewWin viewWin) throws BusinessException
	{
		Long viewwinid = viewWin.getId();
		List<ViewPanel> viewPanels = viewPanelDaoImpl
				.findByViewwinid(viewwinid);
		deleteViewPanelDB(viewPanels);
	}

	private void deleteViewPanelDB(List<ViewPanel> viewPanels)
			throws BusinessException
	{
		for (ViewPanel viewPanel : viewPanels)
		{
			Long viewpanelid = viewPanel.getId();
			List<ViewItem> viewItems = viewPanelDaoImpl.findItems(viewpanelid);
			viewItemDaoImpl.deleteAll(viewItems);
			List<ViewEvent> viewEvents = viewPanelDaoImpl
					.findEvents(viewpanelid);
			viewEventDaoImpl.deleteAll(viewEvents);
			viewPanelDaoImpl.delete(viewPanel);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.impl.ViewCfgService#
	 * findViewPanelByViewwinid(java.lang.Long)
	 */
	public List<ViewPanel> findViewPanelByViewwinid(Long viewwinid)
			throws BusinessException
	{
		logger.info("findViewPanelByViewwinid method run begin.");
		List<ViewPanel> result = viewPanelDaoImpl.findByViewwinid(viewwinid);
		logger.info("findViewPanelByViewwinid method run end.");
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.impl.ViewCfgService#
	 * saveOrUpdateViewPanel(com.adams.access.db.bean.ViewPanel)
	 */
	public void saveOrUpdateViewPanel(ViewPanel viewPanel)
			throws BusinessException
	{
		logger.info("saveOrUpdateViewPanel method run begin.");
		try
		{
			if (viewPanel.getId() > 0 && viewPanel.getVersion() == 0)
			{
				ViewPanel old = viewPanelDaoImpl.get(viewPanel.getId());
				if (null != old)
				{
					viewPanel.setVersion(old.getVersion());
					BeanUtils.copyProperties(viewPanel, old);
					viewPanel = old;
				}
			}
			viewPanelDaoImpl.saveOrUpdate(viewPanel);
			String tablecode = viewPanel.getTablecode();
			Long viewpanelid = viewPanel.getId();
			List<ViewItem> viewItems = viewPanelDaoImpl.findItems(viewpanelid);
			for (ViewItem viewItem : viewItems)
			{
				if (!tablecode.equals(viewItem.getTablecode()))
				{
					viewItemDaoImpl.delete(viewItem);
				}
			}
		} finally
		{
			viewPanelDaoImpl.synchronizationCache();
			viewItemDaoImpl.synchronizationCache();
			viewEventDaoImpl.synchronizationCache();
			viewParseService.clearCache();
			CacheUtil.clearCacheByClass(ViewPanel.class);
			CacheUtil.clearCacheByClass(ViewItem.class);
			CacheUtil.clearCacheByClass(ViewEvent.class);
		}
		logger.info("saveOrUpdateViewPanel method run end.");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.adams.custom.page.mgt.service.ViewCfgService#deleteViewPanels
	 * (java.util.List)
	 */
	public void deleteViewPanels(List<Long> viewPanelids)
			throws BusinessException
	{
		logger.info("deleteViewPanels method run begin.");
		try
		{
			for (Long viewPanelid : viewPanelids)
			{
				ViewPanel viewPanel = viewPanelDaoImpl.get(viewPanelid);
				List<ViewPanel> list = new ArrayList<ViewPanel>();
				list.add(viewPanel);
				deleteViewPanelDB(list);
			}
		} finally
		{
			viewPanelDaoImpl.synchronizationCache();
			viewItemDaoImpl.synchronizationCache();
			viewEventDaoImpl.synchronizationCache();
			viewParseService.clearCache();
			CacheUtil.clearCacheByClass(ViewPanel.class);
			CacheUtil.clearCacheByClass(ViewItem.class);
			CacheUtil.clearCacheByClass(ViewEvent.class);
		}
		logger.info("deleteViewPanels method run end.");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.impl.ViewCfgService#
	 * findViewItemByViewpanelid(java.lang.Long)
	 */
	public List<ViewItem> findViewItemByViewpanelid(Long viewpanelid)
			throws BusinessException
	{
		logger.info("findViewItemByViewpanelid method run begin.");
		List<ViewItem> result = viewPanelDaoImpl.findItems(viewpanelid);
		logger.info("findViewItemByViewpanelid method run end.");
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.adams.custom.page.mgt.service.ViewCfgService#getViewItemById
	 * (java.lang.Long)
	 */
	public ViewItem getViewItemById(Long id) throws BusinessException
	{
		logger.info("getViewItemById method run begin.");
		ViewItem result = viewItemDaoImpl.getByCache(id);
		logger.info("getViewItemById method run end.");
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.impl.ViewCfgService#
	 * saveOrUpdateViewItem(com.adams.access.db.bean.ViewItem)
	 */
	public void saveOrUpdateViewItem(ViewItem viewItem)
			throws BusinessException
	{
		logger.info("saveOrUpdateViewItem method run begin.");
		try
		{
			Long viewpanelid = viewItem.getViewpanelid();
			ViewPanel viewpanel = viewPanelDaoImpl.get(viewpanelid);
			viewItem.setTablecode(viewpanel.getTablecode());
			if (viewItem.getId() > 0 && viewItem.getVersion() == 0)
			{
				ViewItem old = viewItemDaoImpl.get(viewItem.getId());
				if (null != old)
				{
					viewItem.setVersion(old.getVersion());
					BeanUtils.copyProperties(viewItem, old);
					viewItem = old;
				}
			}
			viewItemDaoImpl.saveOrUpdate(viewItem);
		} finally
		{
			viewItemDaoImpl.synchronizationCache();
			viewParseService.clearCache();
			CacheUtil.clearCacheByClass(ViewItem.class);
		}
		logger.info("saveOrUpdateViewItem method run end.");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.adams.custom.page.mgt.service.ViewCfgService#deleteViewItems
	 * (java.util.List)
	 */
	public void deleteViewItems(List<Long> viewItemids)
			throws BusinessException
	{
		logger.info("deleteViewItems method run begin.");
		try
		{
			for (Long viewItemid : viewItemids)
			{
				ViewItem viewItem = viewItemDaoImpl.getByCache(viewItemid);
				viewItemDaoImpl.delete(viewItem);
			}
		} finally
		{
			viewItemDaoImpl.synchronizationCache();
			viewParseService.clearCache();
			CacheUtil.clearCacheByClass(ViewItem.class);
		}
		logger.info("deleteViewItems method run end.");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.impl.ViewCfgService#
	 * findViewEventByViewpanelid(java.lang.Long)
	 */
	public List<ViewEvent> findViewEventByViewpanelid(Long viewpanelid)
			throws BusinessException
	{
		logger.info("findViewEventByViewpanelid method run begin.");
		List<ViewEvent> result = viewPanelDaoImpl.findEvents(viewpanelid);
		logger.info("findViewEventByViewpanelid method run end.");
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.impl.ViewCfgService#
	 * saveOrUpdateViewEvent(com.adams.access.db.bean.ViewEvent)
	 */
	public void saveOrUpdateViewEvent(ViewEvent viewEvent)
			throws BusinessException
	{
		logger.info("saveOrUpdateViewEvent method run begin.");
		if (viewEvent.getId() > 0 && viewEvent.getVersion() == 0)
		{
			ViewEvent old = viewEventDaoImpl.get(viewEvent.getId());
			if (null != old)
			{
				viewEvent.setVersion(old.getVersion());
				BeanUtils.copyProperties(viewEvent, old);
				viewEvent = old;
			}
		}
		viewEventDaoImpl.saveOrUpdate(viewEvent);
		viewEventDaoImpl.synchronizationCache();
		viewParseService.clearCache();
		CacheUtil.clearCacheByClass(ViewEvent.class);
		logger.info("saveOrUpdateViewEvent method run end.");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.adams.custom.page.mgt.service.ViewCfgService#deleteViewEvent
	 * (java.util.List)
	 */
	public void deleteViewEvents(List<Long> viewEventids)
			throws BusinessException
	{
		logger.info("deleteViewEvents method run begin.");
		try
		{
			for (Long viewEventid : viewEventids)
			{
				ViewEvent viewEvent = viewEventDaoImpl.get(viewEventid);
				viewEventDaoImpl.delete(viewEvent);
			}
		} finally
		{
			viewEventDaoImpl.synchronizationCache();
			viewParseService.clearCache();
			CacheUtil.clearCacheByClass(ViewEvent.class);
		}
		logger.info("deleteViewEvents method run end.");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.ViewCfgService#
	 * getParseColumnCOdeTree(java.lang.String)
	 */
	@SuppressWarnings("unchecked")
	public List<Map> getParseColumnCodeTree(String tablecode)
			throws BusinessException
	{
		logger.info("getParseColumnCodeTree method run begin.");
		List<Map> result = new ArrayList<Map>();
		DicTable dicTable = dicTableService.getDicTable(tablecode);
		List<DicColumn> dicColumns = dicTableService
				.findDicColumnsByTablecode(tablecode);

		for (DicColumn dicColumn : dicColumns)
		{
			Map treeMap = new HashMap();
			treeMap.put(ViewTreeConfigDTO.ID_FIELD, UUID.randomUUID()
					.toString());
			treeMap.put(ViewTreeConfigDTO.DISPLAN_FIELD, dicColumn
					.getColumnname());
			treeMap.put("columncode", dicColumn.getDicColumnPK()
					.getColumncode());
			treeMap.put(ViewTreeConfigDTO.TREE_LEAF, true);
			treeMap.put(ViewTreeConfigDTO.TREE_CHECKED, false);
			String enumeratemap = dicColumn.getEnumeratemap();
			if (null != enumeratemap && !"".equals(enumeratemap.trim()))
			{
				List<Map> eMaps = new ArrayList<Map>();
				Map eMap = new HashMap();
				eMap.put(ViewTreeConfigDTO.ID_FIELD, UUID.randomUUID()
						.toString());
				eMap.put(ViewTreeConfigDTO.DISPLAN_FIELD, "value");
				eMap.put("columncode", "value");
				eMap.put(ViewTreeConfigDTO.TREE_LEAF, true);
				eMap.put(ViewTreeConfigDTO.TREE_CHECKED, false);
				eMaps.add(eMap);
				treeMap.put(ViewTreeConfigDTO.TREE_LEAF, false);
				treeMap.put(ViewTreeConfigDTO.TREE_CHILDREN, eMaps);
			} else
			{
				// 考虑总体性能,树层次为5层
				String keycolumn = dicTable.getKeycolumns();
				if (!dicTable.isCompositeKey()
						&& dicColumn.getDicColumnPK().getColumncode().equals(
								keycolumn))
				{
					buildColumnCodeTree(treeMap, dicColumn.getTargettable(), 5);
				} else
				{
					buildColumnCodeTree(treeMap, dicColumn.getSourcetable(), 5);
				}

			}

			result.add(treeMap);
		}
		// TODO Auto-generated method stub
		logger.info("getParseColumnCodeTree method run end.");
		return result;
	}

	/**
	 * Description : 递归产生树
	 * 
	 * @param columnMap
	 * @param tablecode
	 * @param id
	 * @param level
	 * @throws BusinessException
	 * 
	 */
	@SuppressWarnings("unchecked")
	private void buildColumnCodeTree(Map columnMap, String tablecode, int level)
			throws BusinessException
	{
		if (level > 0 && !ViewUtil.isNuLLStr(tablecode))
		{
			level--;
			DicTable dicTable = dicTableService.getDicTable(tablecode);
			List<DicColumn> dicColumns = dicTableService
					.findDicColumnsByTablecode(tablecode);
			List<Map> result = new ArrayList<Map>();
			for (DicColumn dicColumn : dicColumns)
			{
				Map treeMap = new HashMap();
				treeMap.put(ViewTreeConfigDTO.ID_FIELD, UUID.randomUUID()
						.toString());
				treeMap.put(ViewTreeConfigDTO.DISPLAN_FIELD, dicColumn
						.getColumnname());
				treeMap.put("columncode", dicColumn.getDicColumnPK()
						.getColumncode());
				treeMap.put(ViewTreeConfigDTO.TREE_LEAF, true);
				treeMap.put(ViewTreeConfigDTO.TREE_CHECKED, false);
				String enumeratemap = dicColumn.getEnumeratemap();
				if (null != enumeratemap && !"".equals(enumeratemap.trim()))
				{
					List<Map> eMaps = new ArrayList<Map>();
					Map eMap = new HashMap();
					eMap.put(ViewTreeConfigDTO.ID_FIELD, UUID.randomUUID()
							.toString());
					eMap.put(ViewTreeConfigDTO.DISPLAN_FIELD, "value");
					eMap.put("columncode", "value");
					eMap.put(ViewTreeConfigDTO.TREE_LEAF, true);
					eMap.put(ViewTreeConfigDTO.TREE_CHECKED, false);
					eMaps.add(eMap);
					treeMap.put(ViewTreeConfigDTO.TREE_LEAF, false);
					treeMap.put(ViewTreeConfigDTO.TREE_CHILDREN, eMaps);
				} else
				{
					String keycolumn = dicTable.getKeycolumns();
					if (!dicTable.isCompositeKey()
							&& dicColumn.getDicColumnPK().getColumncode()
									.equals(keycolumn))
					{
						buildColumnCodeTree(treeMap,
								dicColumn.getTargettable(), level);
					} else
					{
						buildColumnCodeTree(treeMap,
								dicColumn.getSourcetable(), level);
					}
				}

				result.add(treeMap);
			}
			if (result.size() > 0)
			{
				columnMap.put(ViewTreeConfigDTO.TREE_LEAF, false);
				columnMap.put(ViewTreeConfigDTO.TREE_CHILDREN, result);
			}
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.adams.custom.page.mgt.service.ViewCfgService#getViewPanelById
	 * (java.lang.Long)
	 */
	@Override
	public ViewPanel getViewPanelById(Long id) throws BusinessException
	{
		logger.info("getViewPanelById method run begin.");
		ViewPanel result = viewPanelDaoImpl.get(id);
		logger.info("getViewPanelById method run end.");
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.adams.custom.page.mgt.service.ViewCfgService#getViewEventById
	 * (java.lang.Long)
	 */
	@Override
	public ViewEvent getViewEventById(Long id) throws BusinessException
	{
		logger.info("getViewEventById method run begin.");
		// TODO Auto-generated method stub
		ViewEvent result = viewEventDaoImpl.get(id);
		logger.info("getViewEventById method run end.");
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.ViewCfgService#
	 * findViewWinByViewPanelIdAndWintype(java.lang.String, java.lang.String)
	 */
	@Override
	public List<ViewWin> findViewWinByViewPanelIdAndWintype(
			String viewpanelidStr, String wintype) throws BusinessException
	{
		logger.info("findViewWinByViewPanelIdAndWintype method run begin.");
		Long viewpanelId = ViewUtil.getViewControlId(viewpanelidStr);
		ViewPanel viewPanel = this.viewPanelDaoImpl.get(viewpanelId);
		Long viewwinid = viewPanel.getViewwinid();
		ViewWin viewWin = viewWinDaoImpl.get(viewwinid);
		Long menuid = viewWin.getMenuid();
		List<ViewWin> result = findViewWinByMenuidAndWintype(menuid, wintype);
		logger.info("findViewWinByViewPanelIdAndWintype method run end.");
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.ViewCfgService#
	 * getViewPanelFilterById(java.lang.Long)
	 */
	@Override
	public ViewPanelFilter getViewPanelFilterById(Long id)
			throws BusinessException
	{
		// TODO Auto-generated method stub
		logger.info("getViewPanelFilterById parameter id=" + id);
		ViewPanelFilter result = viewPanelFilterDaoImpl.get(id);
		if (null != result)
		{
			logger.info("getViewPanelFilterById return result ="
					+ result.toString());
		} else
		{
			logger.info("getViewPanelFilterById return result is null");
			throw new BusinessException("data.noexists.exception");
		}
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.ViewCfgService#
	 * findViewPanelFilterByViewpanelid(java.lang.String)
	 */
	@Override
	public List<ViewPanelFilter> findViewPanelFilterByViewpanelid(
			String viewpanelidStr) throws BusinessException
	{
		// TODO Auto-generated method stub
		logger
				.info("findViewPanelFilterByViewpanelid parameter viewpanelidStr="
						+ viewpanelidStr);
		Long viewpanelId = ViewUtil.getViewControlId(viewpanelidStr);
		List<ViewPanelFilter> result = viewPanelFilterDaoImpl
				.findByViewPanelid(viewpanelId);
		logger.info("findViewPanelFilterByViewpanelid return result size is "
				+ result.size());
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.ViewCfgService#
	 * saveOrUpdateViewPanelFilter
	 * (com.adams.access.db.bean.ViewPanelFilter)
	 */
	public void saveOrUpdateViewPanelFilter(ViewPanelFilter viewPanelFilter)
			throws BusinessException
	{
		viewPanelFilterDaoImpl.saveOrUpdate(viewPanelFilter);
		viewPanelFilterDaoImpl.synchronizationCache();
		viewParseService.clearCache();
		CacheUtil.clearCacheByClass(ViewPanelFilter.class);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.ViewCfgService#
	 * deleteViewPanelFilters(java.util.List)
	 */
	public void deleteViewPanelFilters(List<Long> viewPanelFilterids)
			throws BusinessException
	{
		try
		{
			for (Long viewPanelFilterid : viewPanelFilterids)
			{
				ViewPanelFilter viewPanelFilter = viewPanelFilterDaoImpl
						.get(viewPanelFilterid);
				viewPanelFilterDaoImpl.delete(viewPanelFilter);
			}
		} finally
		{
			viewPanelFilterDaoImpl.synchronizationCache();
			viewParseService.clearCache();
			CacheUtil.clearCacheByClass(ViewPanelFilter.class);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.adams.custom.page.mgt.service.ViewCfgService#
	 * synchronizationCache()
	 */
	public void synchronizationCache() throws BusinessException
	{
		logger.info("synchronizationCache method run begin.");
		viewWinDaoImpl.synchronizationCache();
		viewPanelDaoImpl.synchronizationCache();
		viewEventDaoImpl.synchronizationCache();
		viewItemDaoImpl.synchronizationCache();
		viewPanelFilterDaoImpl.synchronizationCache();
		logger.info("synchronizationCache method run end.");
	}
}
